package com.family.web.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * 拦截具体的资源：/index.jsp：只有访问index.jsp时才会被拦截
 * 目录拦截：/user/*：访问/user下的所有资源，都会被拦截
 * 后缀名拦截：*.jsp：访问后缀名为jsp的资源，都会被拦截
 * 拦截所有：/*：访问所有资源，都会被拦截
 */
//@WebFilter("/hello.jsp")
@WebFilter("/*")
public class FilterDemo2 implements Filter {


    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {

        //1. 放行前，对 request数据进行处理
        System.out.println("2.FilterDemo...");

        //放行
        chain.doFilter(request,response);
        //2. 放行后，对Response 数据进行处理
        System.out.println("4.FilterDemo...");
    }

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }



    @Override
    public void destroy() {

    }
}
